<template>
  <div class="form-group">
    <label class="col-sm-4 control-label">事件来源：</label>
    <div class="col-sm-8">
      <select class="form-control select2" style="width: 100%;" v-model="selected" @change="$emit('input', $event.target.value)">
        <option value="" disabled selected style='display:none;'>请选择</option>        
        <option value="全部">全部</option>

        <option v-for="lst in originList" :value="lst.value" :key="lst.value">{{lst.label}}</option>
      </select>
    </div>
  </div>
</template>

<script>
export default {
    props: {
        value: [String, Number]
    },
    data() {
        return {
            originList: [],
            selected: this.value
        };
    },
    watch: {
        value() {
            this.selected = this.value;
        }
    },
    mounted() {
        this.getSelOrderSource();
    },
    methods: {
        getSelOrderSource() {
            this.$api.ticket.list.selOrderSource().then(res => {
                if (res.success) {
                    // console.log(res)
                    for (let item in res.data) {
                        let arr = { label: "", value: "" };
                        arr.label = res.data[item].sourceName;
                        arr.value = res.data[item].sourceName;
                        this.originList.push(arr);
                    }
                }
            });
        }
    }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.control-label {
    padding: 0;
    line-height: 34px;
}
input,
select,
textarea {
    border-radius: 5px;
}
.fa-asterisk {
    font-size: 1px;
    color: red;
}
</style>
